﻿using log4net.Appender;
using MiniFox.Data;
using MiniFox.Data.Configurations;

namespace MiniFox.Log
{
    /// <summary>
    /// 
    /// </summary>
    public class MiniDatabaseAppender : AdoNetAppender
    {
        static readonly DatabaseConfiguration databaseConfiguration;
        static MiniDatabaseAppender()
        {
            databaseConfiguration = Database.Configuration;
        }
        static DatabaseConfiguration DatabaseConfiguration
        {
            get
            {
                return databaseConfiguration;
            }
        }

        ConnectionConfiguration ConnectionConfiguration
        {
            get
            {
                var connectionStringSetting = DatabaseConfiguration.Connections[this.ConnectionStringName];
                return connectionStringSetting;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionStringContext"></param>
        /// <returns></returns>
        protected override string ResolveConnectionString(out string connectionStringContext)
        {
            connectionStringContext = ConnectionConfiguration.ConnectionString;
            return ConnectionConfiguration.ConnectionString;
        }
    }
}
